package main;

import fragmentAppl.Behavior;
import fragmentAppl.Characteristics;
import impl.AgentRef;
import impl.Medium;
import impl.MediumImpl;

import java.util.ArrayList;
import java.util.Vector;

import tools.Debug;
import tools.Fragment;
import tools.FragmentDirectory;
import tools.FragmentState;
import tools.MMME;
import tools.MMMEDirectory;



public class FragmentFactory {
		
	public static Fragment create( 	String id, 
									Vector<String> _output, 
									Vector<String> _input,
									int preference,
									FragmentDirectory fragDir,
									MMMEDirectory elemDir
								  ) 
		{
		ArrayList<MMME> input = new ArrayList<MMME>();
		ArrayList<MMME> output = new ArrayList<MMME>();
		for (int i=0; i<_input.size();i++)
			input.add(new MMME(_input.get(i)));
		for (int i=0; i<_output.size();i++)
			output.add(new MMME(_output.get(i)));
		
		//Stimulation stimTemp=new Stimulation(preference);					//Needed by current MAY implementation
		//ContactHandler contTemp=new ContactHandler(elemDir,fragDir);	//Needed by current MAY implementation
		 Medium medium = new MediumImpl(1099);
		 
//		 System.out.println("input: "+input.size());
//		 System.out.println("output: "+output.size());
//		 System.out.println("elemen: "+elemDir.getMMMEList().size());
//		 System.out.println("fragdir: "+fragDir.getListeFragment().size());

//		 System.out.println("preference: "+preference);
		 
		 

		 AgentRef ar = medium.create(new Characteristics(input,output,preference),new Behavior(elemDir,fragDir));
		// Debug.println(ar.toString()+" : start");
		
//		    FragmentAgent agent= new FragmentAgent(
//		    		new CreateImpl(medium,ar), 
//		    		new MessageImpl(medium),
//		    		new LifeCycleImpl(),
//		    		new Characteristics(input,output,preference),
//		    		new Representations(),
//		    		new Skills(),
//		    		new Behavior(elemDir,fragDir));
//			
		
		    
		//stimTemp.linkReference(agent);		//Needed by current MAY implementation
		//contTemp.linkReference(agent);		//Needed by current MAY implementation
		
		//agent.start();
		 Fragment agent=new Fragment(input,output,ar.toString(),FragmentState.Referenced,preference,0);
		 return agent;
		 
		}
}
